package com.bone.payment.utils;

import java.text.DecimalFormat;
import java.util.Date;

import com.bone.util.DateUtil;

public class SerialUtil  {
	
	public final static String SIG_PRIVATE_KEY="asiuepf8ur98cvjh823498qewufsdujfklasef";
	
	
	/**
	 * 对帐流水号(24位).
	 * @param objectId
	 * @return
	 */
	public static String generate24ObjectId(Long objectId) {
		String serial = DateUtil.getFormatDate(new Date(), "yyyyMMddHHmmssSSS") + objectId;
		return  serial;
	}

	
	
	/**
	 * 对帐流水号(10位).
	 * @param objectId
	 * @return
	 */
	public static String generate10ObjectId(final Long objectId, final Long times) {
		DecimalFormat orderIdFormat = null;
		if (objectId.toString().length() == 1) {
			orderIdFormat = new DecimalFormat("000000000");
		} else if (objectId.toString().length() == 2) {
			orderIdFormat = new DecimalFormat("00000000");
		} else if (objectId.toString().length() == 3) {
			orderIdFormat = new DecimalFormat("0000000");
		} else if (objectId.toString().length() == 4) {
			orderIdFormat = new DecimalFormat("000000");
		} else if (objectId.toString().length() == 5) {
			orderIdFormat = new DecimalFormat("00000");
		} else if (objectId.toString().length() == 6) {
			orderIdFormat = new DecimalFormat("0000");
		} else if (objectId.toString().length() == 7) {
			orderIdFormat = new DecimalFormat("000");
		} else if (objectId.toString().length() == 8) {
			orderIdFormat = new DecimalFormat("00");
		}else {
			orderIdFormat = new DecimalFormat("0000000000");
		}
		String serial= objectId + orderIdFormat.format(times);
		return serial;
	}
	
}
